package com.tanhua.server.controller;





import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.tanhua.domain.db.Answer;
import com.tanhua.domain.db.AnswerReceive;
import com.tanhua.server.service.SoulService;


import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.websocket.server.PathParam;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/testSoul")
@Slf4j
public class SoulController {

    @Autowired
    private SoulService soulService;
    /**
     * 测灵魂-问卷列表
     * 接口路径：GET/testSoul
     */
    @GetMapping
    public ResponseEntity<Object> testSoul(){
        return soulService.testSoul();
    }

    /**
     * 测灵魂-提交问卷
     * 接口路径：POST/testSoul
     */
    @PostMapping
    public ResponseEntity<Object> submitTestSoul(@RequestBody AnswerReceive answerReceive){
        //获取了所有试题的id和用户选的答案
        List<Answer> answers = answerReceive.getAnswers();
        return soulService.submitTestSoul(answers);
    }

    /**
     * 测灵魂-查看结果
     * 接口路径：GET/testSoul/report/:id
     */
    @GetMapping("/report/{id}")
    public ResponseEntity<Object> showReport(@PathVariable("id") String id){

        return soulService.showReport(id);
    }
}
